package com.gitee.wsl.compose.ui.calendar.view

import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.sp
import com.gitee.wsl.ext.base.next
import com.gitee.wsl.time.calendar.bean.Week
import com.gitee.wsl.time.local.KlockLocale
import kotlinx.datetime.DayOfWeek

typealias WeekHeaderFooterSlate = @Composable ColumnScope.(Week, firstDayOfWeek: DayOfWeek, KlockLocale) -> Unit

object WeekHeaderFooter

@OptIn(ExperimentalStdlibApi::class)
val WeekHeaderFooter.defaultHeader :WeekHeaderFooterSlate get() = { week, dayOfWeek,local ->
    var nextDayOfWeek = dayOfWeek
    Row(
        modifier = Modifier
            .fillMaxWidth()
            .testTag("MonthHeader"),
    ) {
        week.days.forEach { day ->
            Text(
                modifier = Modifier.weight(1f),
                textAlign = TextAlign.Center,
                fontSize = 15.sp,
                text = local.getDayOfWeekName(nextDayOfWeek),
                fontWeight = FontWeight.Medium,
            )
            nextDayOfWeek = nextDayOfWeek.next
        }
    }
}
